package com.pkuse.bjousystem.repository.school;

import com.pkuse.bjousystem.repository.school.SchoolIDOption;
import org.apache.commons.lang3.StringUtils;

import java.util.*;

public class SchoolTableOptions {

    public static final String NDXQ_KEY = "ndxq";
    public static final String XSLB_KEY = "xslb";
    public static final String ZYLB_KEY = "zylb";
    public static final String SPLIT = ",";
    public static final String DELIMITER = "#";

    public SchoolTableOptions(Map<String, String> rqBody) {
        this.schoolID = new SchoolIDOption(rqBody);
        this.nianDuXueQi = Optional.ofNullable(StringUtils.trimToNull(rqBody.get(NDXQ_KEY))).map(p -> new HashSet<>(Arrays.asList(p.split(SPLIT))));
        this.xueShengLeiBie = Optional.ofNullable(StringUtils.trimToNull(rqBody.get(XSLB_KEY))).map(p -> new HashSet<>(Arrays.asList(p.split(SPLIT))));
        this.zhuanYeMingCheng = Optional.ofNullable(StringUtils.trimToNull(rqBody.get(ZYLB_KEY))).map(p -> new HashSet<>(Arrays.asList(p.split(SPLIT))));
    }

    public SchoolIDOption getSchoolID() {
        return schoolID;
    }

    public Optional<Set<String>> getNianDuXueQi() {
        return nianDuXueQi;
    }

    public Optional<Set<String>> getXueShengLeiBie() {
        return xueShengLeiBie;
    }

    public Optional<Set<String>> getZhuanYeMingCheng() {
        return zhuanYeMingCheng;
    }

    private SchoolIDOption schoolID;
    private Optional<Set<String>> nianDuXueQi;
    private Optional<Set<String>> xueShengLeiBie;
    private Optional<Set<String>> zhuanYeMingCheng;

    @Override
    public String toString() {
        return "ListGraduationOptions{" +
                "schoolID='" + schoolID + '\'' +
                ", nianDuXueQi=" + nianDuXueQi +
                ", xueShengLeiBie=" + xueShengLeiBie +
                ", zhuanYeMingCheng=" + zhuanYeMingCheng +
                '}';
    }

}
